﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>申请体验</title>

    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    

    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });

        //MobileCom.delCookie("szhlcode");
        //if (MobileCom.getCookie("szhlcode") == null) {
        //    MobileCom.setCookie("szhlcode", "aeac70cc-c359-45f2-90ac-78cb7abe5816", 7);
        //}

        var model = avalon.define({
            $id: "khmodel",
            ctData: { "KHLeiBie": "意向客户", "KHName": "", "KHXinBie": "先生", "KHPhone": "", "KHDW": "", "KHZhiWu": "", "KHAdress": "", "KHFXRS": "" },
            cpData: [],
            qymc: "",
            savedata: function () {
                if (model.ctData.KHLeiBie == "") {
                    $.tips({
                        content: "请选择类别",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }
                if (model.ctData.KHName == "") {
                    $.tips({
                        content: "请输入姓名",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }
                if (model.ctData.KHXinBie == "") {
                    $.tips({
                        content: "请选择性别",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }
                if (model.ctData.KHPhone == "") {
                    $.tips({
                        content: "请输入手机号",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }
                else {
                    var reg = /^(?:13\d|14\d|15\d|17\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
                    if (!reg.test(model.ctData.KHPhone)) {
                        $.tips({
                            content: "手机号格式错误",
                            stayTime: 2000,
                            type: "warn"
                        })
                        return;
                    }
                }
                if (model.ctData.KHDW == "") {
                    $.tips({
                        content: "请输入公司名称",
                        stayTime: 2000,
                        type: "warn"
                    })
                    return;
                }

                var lg = $.loading({
                    content: '保存中...',
                })
                $.post("/API/COMMAPI.ashx?Action=ADDKHGL&r=" + Math.random(), { "data": JSON.stringify(model.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            //window.location.replace("UI_KHGL_LIST.html?r=" + Math.random());
                            $("#content").hide();
                            $("#sqcg").show();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            }
        });

        avalon.ready(function () {
            var lg = $.loading({
                content: '加载中...',
            })
            $.getJSON("/API/SZHLAPI.ashx?action=GETQYINFO&r=" + Math.random(), {}, function (r) {
                lg.hide();
                if (r.ErrorMsg == "") {
                    model.qymc = r.Result.QYName;
                }
            })
        })
    </script>
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }

        .ms-controller, [ms-controller] {
            display: none;
        }
    </style>
</head>
<body ms-controller="khmodel">
    <div id="content" >
        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()" id="save">
                申请体验
            </button>
        </div>
        <!--<div class="ui-avatar-lg" style="margin:20px auto;width:100px;height:100px">
            <span style="background-image: url(/images/Log/SZHL.jpg)"></span>
        </div>-->

        <img src="/images/Log/SZHL.jpg" style="margin: 20px auto; width: 100px; height: 100px; display: block;" />
        <p style="margin-bottom:10px;text-align:center">{{qymc}}</p>
        <p style="margin-bottom:10px;text-align:center">邀请你体验企业号移动办公系统</p>
        <section class="ui-container">
            <div class="ui-form ui-border-t">
                
                <div class="ui-form-item ui-border-b">
                    <label>
                        姓名
                    </label>
                    <input type="text" autofocus="autofocus" placeholder="请输入姓名" ms-duplex="ctData.KHName" />
                </div>
                <div class="ui-form-item ui-border-b ">
                    <label>
                        性别
                    </label>
                    <div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.KHXinBie">
                            <option value="女士">女士</option>
                            <option value="先生">先生</option>
                        </select>
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        手机号
                    </label>
                    <input type="tel" placeholder="请输入手机号" ms-duplex="ctData.KHPhone" />
                </div>
                <!--<div class="ui-form-item ui-border-b ui-form-item-r">
                    <label>
                        验证码
                    </label>
                    <input type="text" placeholder="请输入验证码" style="padding-left:95px;padding-right:120px" />
                    <button type="button" class="ui-border-l">重新发送</button>
                </div>-->
                <div class="ui-form-item ui-border-b">
                    <label>
                        公司名称
                    </label>
                    <input type="text" placeholder="请输入公司名称" ms-duplex="ctData.KHDW" />

                </div>
            </div>
        </section>
    </div>

    <div style="display: none;" id="sqcg">
        <div>
            <img src="../Images/kf.jpg" style="width:100%" />
        </div>
    </div>
</body>

</html>

